import java.util.*;

public class Main {
    public static int gcd(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    public static int lcm(int a, int b) {
        return a / gcd(a, b) * b; // 防止溢出
    }

    public static List<Integer> fun(int n){
        List<Integer> ans = new ArrayList<>();
        for(int i = 1; i <= n; i++){
            if(n % i == 0){
                ans.add(i);
            }
        }
        return ans;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for(int i=2;i<=n;i++) {
            List<Integer> list = fun(i);
            int sum = 0;
            for(int j=0;j<list.size();j++) {
                if(list.get(j) != i){
                    sum += list.get(j);
                }
            }
            if(sum == i){
                System.out.print(i+" its factors are ");
                for(int j=0;j<list.size();j++){
                    if(list.get(j) != i){
                        System.out.print(list.get(j));
                        System.out.print(' ');
                    }
                }
                System.out.println();
            }
        }
    }
}
